package com.sunlx.product.db;

import com.sunlx.product.dictionary.DatabaseTypeEnum;
import com.sunlx.product.generatesql.MysqlSqlNormal;
import com.sunlx.product.generatesql.OracleSqlNormal;
import com.sunlx.product.generatesql.SqlStrategy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 *
 * @author Sunluxin
 * @date 2023/1/12 15:51
 */
@Configuration
public class DatabaseTypeConfig {
    @Value("${spring.profile.active}")
    private String dbType;

    @Bean
    public SqlStrategy sqlStrategy(){
        if(DatabaseTypeEnum.ORACLE.getType().equals(dbType)) {
            return new OracleSqlNormal();
        }
        else if (DatabaseTypeEnum.MYSQL.getType().equals(dbType)){
            return new MysqlSqlNormal();
        }
        // TODO: 2023/1/12 增加不同的数据库
        else {
            return new OracleSqlNormal();
        }
    }


}
